using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PlatformShoot
{
    public class Player : MonoBehaviour
    {
        private Rigidbody2D mRig;
        private float mGroundMoveSpeed = 10f;
        private float mJumpForce = 12f;
        private void Start() 
        {
            mRig = GetComponent<Rigidbody2D>();//获取rigidbody2d   
        }

        private void FixedUpdate() 
        {
            if(Input.GetKeyDown(KeyCode.Space))
            {
                mRig.velocity = new Vector2(mRig.velocity.x,mJumpForce);//跳跃：保持x轴不动，动y轴

            }
            mRig.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * mGroundMoveSpeed,mRig.velocity.y);//左右移动，保持y轴不动，动x轴

            //getaxisraw("horizontal") 调速度，值为1 or -1  *10以加速
        }
    }
}


